/**   
 * Copyright 2011 COMERE Harold
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package etrl.core;

import com.googlecode.gwtgl.binding.WebGLRenderingContext;

/**
 * \class Engine
 * \brief Singleton storing current GL context to make it accessible everywhere. It should be changed...
 * @author harold
 *
 */
public class Engine
{
	/**
	 * Singleton instance.
	 */
	private static Engine _instance = null;
	
	/**
	 * Current GL context.
	 */
	private WebGLRenderingContext _gl = null;
	
	/**
	 * \brief Initializes the engine.
	 */
	private Engine()
	{
		
	}
	
	/**
	 * \brief GL context getter.
	 * @return Current GL context.
	 */
	public WebGLRenderingContext getGL()
	{
		return _gl;
	}
	
	/**
	 * \brief GL context setter.
	 * @param[in] gl GL context to set.
	 */
	public void setGL(WebGLRenderingContext gl)
	{
		_gl = gl;
	}
	
	/**
	 * \brief Singleton instance getter.
	 * @return Singleton instance.
	 */
	public static Engine getInstance()
	{
		if(_instance == null)
			_instance = new Engine();
		
		return _instance;
	}
}
